error=0
P=[]
s=input('Введите числа: ')
if s.count(' ')!=2:
    print('Wrong input')
else:
    a,b,c=map(str, s.split())


    if 'one' in a:
        a='1'
    if 'two' in a:
        a='2'
    if 'three' in a:
        a='3'
    if 'four' in a:
        a='4'
    if 'five' in a:
        a='5'
    if 'six' in a:
        a='6'
    if 'seven' in a:
        a='7'
    if 'eight' in a:
        a='8'
    if 'nine' in a:
        a='9'
    if 'zero' in a:
        a='0'
    else:
        error+=1

    if 'one' in b:
        b='1'
    if 'two' in b:
        b='2'
    if 'three' in b:
        b='3'
    if 'four' in b:
        b='4'
    if 'five' in b:
        b='5'
    if 'six' in b:
        b='6'
    if 'seven' in b:
        b='7'
    if 'eight' in b:
        b='8'
    if 'nine' in b:
        b='9'
    if 'zero' in b:
        b='0'
    else:
        error+=1


    if 'one' in c:
        c='1'
    if 'two' in c:
        c='2'
    if 'three' in c:
        c='3'
    if 'four' in c:
        c='4'
    if 'five' in c:
        c='5'
    if 'six' in c:
        c='6'
    if 'seven' in c:
        c='7'
    if 'eight' in c:
        c='8'
    if 'nine' in c:
        c='9'
    if 'zero' in c:
        c='0'
    else:
        error+=1

    if error==0:
        d=int(a+b+c)
        print(d)
        for x in range(d-100,d+100):
            flag=0
            for i in range(2,x):
                if x%i==0:
                    flag=1
                    break
            if flag==0:
                P.append(x)
        print(P)

        min=1000
        for x in P:
            r=d-x
            if r<0:
                r*=-1
            if r<min:
                min=r
                sred=x
        print(sred)
    else:
        print('Wrong input')
        
    
